package com.github.wxiaoqi.security.auth.config;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import cn.hutool.setting.Setting;
import lombok.Getter;
import lombok.Setter;

@Component
public class JwtProperties {
	@Value("config/jwt-${spring.profiles.active}.setting")
	private String env;
	
	@Getter
    private String tokenHeader;
	
	@Getter
	private int expire;
	
	@Getter
	private String rsaSecret;
	
	@Getter
	@Setter
	private byte[] userPubKey;
	@Getter
	@Setter
    private byte[] userPriKey;
	@Getter
	@Setter
    private byte[] servicePriKey;
	@Getter
	@Setter
    private byte[] servicePubKey;
	
	@PostConstruct
	private void init() {
		Setting s = new Setting(env,true);
		tokenHeader = s.getStr("token-header");
		expire = s.getInt("expire");
		rsaSecret = s.getStr("rsa-secret");
	}
}
